
/* This do file generates the results for the project "Historical Family Types and Female Representation: Persistence and Change"
Prepared by Aina Gallego, Didac Queralt, and Ana Tur-Prats

Structure of the do file: each figure and table in the main paper and in the appendix is marked by a bookmark.

New users please note that the 'preserve' and 'restore' commands do not work in earlier versions of Stata. In that case, the relevant dataset might need to be reopened.
*/


clear all
set mo off

* New user change this path:
cd "C:\Users\atur-prats\Desktop\Replication_JoP"

use "Datasets/01_processeddata/main_analysis_dataset.dta", clear


* Figure 1: Theory

**# Figure 2: Historical Family Types
* Figure 2a: Average number of women within household
hist stem, xtitle (Average number of married and widowed women per household) color(%60) xline(1.05, lwidth(.5) lcolor(black))
graph export "Figures/Figure2a.pdf", replace

*Note: Figure 2b is made with R. Code on a different folder

*****************************************************************************
**# Table 1: Main Results
reg genderpc stem_std, cluster(codiine)
outreg2 using "Tables/Table1.tex", replace dec(3) adj

reg genderpc stem_std numparties pop pop2 bigcity, cluster(codiine)
outreg2 using "Tables/Table1.tex", append dec(3) adj

reg genderpc stem_std numparties pop pop2 bigcity sup coastal calories_muni temperature precip ruggedness latitude longitude, cluster(codiine)
outreg2 using "Tables/Table1.tex", append dec(3) adj

reghdfe genderpc stem_std numparties pop pop2 bigcity sup coastal calories_muni temperature precip ruggedness latitude longitude, abs(year) cluster(codiine)
outreg2 using "Tables/Table1.tex", append dec(3) adj

reghdfe genderpc stem_std numparties pop pop2 bigcity sup coastal calories_muni temperature precip ruggedness latitude longitude, abs(year codccaa) cluster(codiine)
outreg2 using "Tables/Table1.tex", append dec(3) adj 

reghdfe genderpc stem_std numparties pop pop2 bigcity sup coastal calories_muni temperature precip ruggedness latitude longitude, abs(year#codccaa) cluster(codiine)
outreg2 using "Tables/Table1.tex", append dec(3) adj

reg genderpc stem_dummy numparties pop pop2 bigcity sup coastal calories_muni temperature precip ruggedness latitude longitude, cluster(codiine)
outreg2 using "Tables/Table1.tex", append dec(3) adj 

**# Table 2: Robustness Checks

reghdfe genderpc stem_std numparties pop pop2 bigcity sup coastal calories_muni temperature precip ruggedness latitude longitude sex_ratio, abs(year#codccaa) cluster(codiine)
outreg2 using "Tables/Table2.tex", replace dec(3) adj

reghdfe genderpc stem_std numparties pop pop2 bigcity sup coastal calories_muni temperature precip ruggedness latitude longitude  singles_per_inhab, abs(year#codccaa) cluster(codiine)
outreg2 using "Tables/Table2.tex", append dec(3) adj

reghdfe genderpc stem_std numparties pop pop2 bigcity sup coastal calories_muni temperature precip ruggedness latitude longitude ///
share_priests share_nuns_monks share_mass_att, abs(year#codccaa) cluster(codiine)
outreg2 using "Tables/Table2.tex", append dec(3) adj

reghdfe genderpc stem_std numparties pop pop2 bigcity sup coastal calories_muni temperature precip ruggedness latitude longitude ///
ratio_laborers_landlords share_ag_pop, abs(year#codccaa) cluster(codiine)
outreg2 using "Tables/Table2.tex", append dec(3)  adj

reghdfe genderpc stem_std numparties pop pop2 bigcity sup coastal calories_muni temperature precip ruggedness latitude longitude share_migrant, abs(year#codccaa) cluster(codiine)
outreg2 using "Tables/Table2.tex", append dec(3) adj

reghdfe genderpc stem_std numparties pop pop2 bigcity sup coastal calories_muni temperature precip ruggedness latitude longitude if (cprov!=8 & cprov!=48), abs(year#codccaa) cluster(codiine)
outreg2 using "Tables/Table2.tex", append dec(3) adj

reghdfe genderpc stem_std numparties pop pop2 sup coastal calories_muni temperature precip ruggedness latitude longitude if bigcity_stem==0, abs(year#codccaa) cluster(codiine)
outreg2 using "Tables/Table2.tex", append dec(3) adj


**# Figure 3: Dynamic Results
preserve
reghdfe genderpc c.stem_std##i.year pop pop2 numparties bigcity sup coastal calories_muni temperature ruggedness precip longitude latitude, abs(codccaa) cluster(codiine) 
margins year, dydx(stem_std) saving(myfile, replace)
bysort year: sum genderpc if e(sample)
* Mean of DV 
* This code computes the mean of the DV per year and saves it.
reghdfe genderpc c.stem_std##i.year pop pop2 numparties bigcity sup coastal calories_muni temperature ruggedness precip longitude latitude, abs(codccaa) cluster(codiine)
keep if e(sample)
bysort year: egen mean_genderpc = mean(genderpc) 
bysort year: gen count = _n
keep if count == 1
keep year mean_genderpc
sort year
gen election = _n
keep election mean_genderpc
save mean_dv.dta, replace
* Merge Margins' estimates and mean of DV
use myfile, clear
gen election = _n
merge 1:1 election using "mean_dv.dta"
gen relative_impact = 100*_margin/mean_genderpc
* Make all weights positive
gen pos_relative_impact = abs(relative_impact)
*set scheme stcolor
twoway (scatter _margin _m1  [w=pos_relative_impact], sort mlcolor(black))  (rcap _ci_lb _ci_ub _m1, sort pstyle(ci) color(navy) legend(off) yline(0) xlab(1976 " "  1979 `" "1979" "(2.92)" "'  1983 `" "1983" "(4.32)" "' 1987 `" "1987" "(6.81)" "'  1991 `" "1991" "(10.80)" "' 1995 `" "1995" "(15.00)" "' 1999 `" "1999" "(20.97)" "' 2003 `" "2003" "(25.58)" "' 2007 `" "2007" "(30.07)" "' 2011 `" "2011" "(33.08)" "' 2015 `" "2015" "(36.15)" "' 2017 " ") ytitle("Marginal effect of Stem Family" "on % of Elected Women") xtitle(""))
graph export "Figures/Figure3.pdf", replace
restore

**Mechanisms:
**# Figure 4: Labor Market by Historical Family Type
* To generate this file, we need first to create the file "epa_prov_year_gender.dta"
* using information from the Active Population Survey. This is done in do file
preserve
do "Codes/Figure_4_labor_market.do"
restore

* We merge with info from EPA
merge m:1 cprov year using "Datasets/01_processeddata/epa_prov_year_gender.dta"
*Note: Users using Stata/ME instead of Stata/MP might have issues with the preserve and restore commands
* If that is the case, we recommend opening the dataset again and running the code within the preserve-restore
preserve
collapse work_gap inact_gap unemp_gap, by(year stem_dummy)
twoway (connected work_gap year if stem_dummy==1, lpattern(shortdash)) (connected work_gap year if stem_dummy==0),  ///
	legend(order(1 "Stem family" 2 "Nuclear family")) ///
	title("Gender gap in labor market participation") ytitle("Mean by province") legend(position(6) symy(5) symx(10) size(medium) row(1)) saving(Figures/lmgraph1b.gph, replace)
	
twoway (connected inact_gap year if stem_dummy==1, lpattern(shortdash)) (connected inact_gap year if stem_dummy==0), ///
	legend(order(1 "Stem family" 2 "Nuclear family")) ///
	title("Gender gap in inactivity") ytitle("Mean by province")   legend(position(6) symy(5) symx(10) size(medium) row(1))  saving(Figures/lmgraph2b.gph, replace)
	
twoway (connected unemp_gap year if stem_dummy==1, lpattern(shortdash)) (connected unemp_gap year if stem_dummy==0), ///
	legend(order(1 "Stem family" 2 "Nuclear family")) ///
	title("Gender gap in unemployment") ytitle("Mean by province")  legend(position(6) symy(5) symx(10) size(medium) row(1))   saving(Figures/lmgraph3b.gph, replace)
	
graph combine Figures/lmgraph1b.gph Figures/lmgraph2b.gph Figures/lmgraph3b.gph, ysize(1) xsize(3) col(3) iscale(1.05)
graph export "Figures/Figure4.pdf", replace
capture erase lmgraph1b.gph lmgraph2b.gph lmgraph3b.gph
restore
 

**# Figure 5
preserve
do "Codes/Figure_5_gender_attitudes.do"
restore

 
**# Figure 6: Quotas
preserve
collapse gender, by(year quota_binary stem_dummy)		
twoway (connected gender year if quota_binary==1) (connected gender year if quota_binary==0) ///
if stem_dummy==0, title("Nuclear-Family Regions")  legend(lab(1 "Any party with quota") lab(2 "No party with quota")) ///
ytitle("Share of Female Councilors") saving(Figures/quota_nuclear.gph, replace)
twoway (connected gender year if quota_binary==1) (connected gender year if quota_binary==0) ///
if stem_dummy==1, title("Stem-Family Regions") legend(lab(1 "Any party with quota") lab(2 "No party with quota")) ///
ytitle("Share of Female Councilors") saving(Figures/quota_stem.gph, replace)
graph combine Figures/quota_nuclear.gph Figures/quota_stem.gph,  ysize(8) xsize(16)
graph export "Figures/Figure6.pdf", replace
capture erase quota_nuclear.gph quota_stem.gph
restore

**# Table 3: Quota Analysis with Municipality FE
gen nuclear_dum = 0 if stem_dummy == 1
replace nuclear_dum = 1 if stem_dummy == 0
gen nuclear_cont = -1*stem_std
*column 1 (Both Dummies)
reghdfe genderpc i.nuclear_dum##i.quota_binary pop pop2 numparties bigcity, abs(year codiine) cluster(codiine)
outreg2 using "Tables/Table3.tex", replace dec(3) label adj
*column 2 (Both continuous)
reghdfe genderpc c.nuclear_cont##c.quota pop pop2 numparties bigcity, abs(year codiine) cluster(codiine)
outreg2 using "Tables/Table3.tex", append dec(3) label adj


**# Appendix Tables and Figures

**# Figure A1(a)-(b): reproduced from Duranton et al. (2009). Figure A1(b) is the same as Figure 2(b)

**# Table A1: reproduced from Tur-Prats (2019)

**# Figure A2
preserve
do "Codes/Figure_A2_1860_2001_census.do"
restore

**# Figure A-3: share of women councilors
preserve
collapse genderpc, by(year)		
twoway (connected genderpc year) , ytitle(Percent of women elected to local councils) 
graph export "Figures/FigureA3.pdf", replace
restore


**# Table A-2: Alternative Historical Family Types Thresholds
*** Different stem family dummies: 
reg genderpc stem_dummy2 numparties pop pop2 bigcity sup coastal calories_muni temperature precip ruggedness latitude longitude, cluster(codiine)
outreg2 using "Tables/TableA2.tex", replace dec(3) adj 
reg genderpc stem_dummy numparties pop pop2 bigcity sup coastal calories_muni temperature precip ruggedness latitude longitude, cluster(codiine)
outreg2 using "Tables/TableA2.tex", append dec(3) adj 
reg genderpc stem_dummy3 numparties pop pop2 bigcity sup coastal calories_muni temperature precip ruggedness latitude longitude, cluster(codiine)
outreg2 using "Tables/TableA2.tex", append dec(3) adj 


**# Table A-3: Alternative Historical Family Type Measure
*** new family type measure:
egen stem_all_std = std(stem_all)
reghdfe genderpc stem_all_std numparties pop pop2 bigcity sup coastal calories_muni temperature precip ruggedness latitude longitude, abs(year#codccaa) cluster(codiine)
outreg2 using "Tables/TableA3.tex", replace dec(3) adj 


**# Table A-4: Main results with different standard errors
*baseline (cluster codiine)
reghdfe genderpc stem_std numparties pop pop2 bigcity sup coastal calories_muni temperature precip ruggedness latitude longitude, abs(year#codccaa) cluster(codiine)
outreg2 using "Tables/TableA4.tex", replace dec(3) adj

*cluster cpj (historic)
reghdfe genderpc stem_std numparties pop pop2 bigcity sup coastal calories_muni temperature precip ruggedness latitude longitude, abs(year#codccaa) cluster(hist_cpj)
outreg2 using "Tables/TableA4.tex", append dec(3) adj

* cluster codiine year 
reghdfe genderpc stem_std numparties pop pop2 bigcity sup coastal calories_muni temperature precip ruggedness latitude longitude, abs(year#codccaa) cluster(codiine year)
outreg2 using "Tables/TableA4.tex", append dec(3) adj

*cluster cpj (historic) year
reghdfe genderpc stem_std numparties pop pop2 bigcity sup coastal calories_muni temperature precip ruggedness latitude longitude, abs(year#codccaa) cluster(hist_cpj year)
outreg2 using "Tables/TableA4.tex", append dec(3) adj

*robust
reghdfe genderpc stem_std numparties pop pop2 bigcity sup coastal calories_muni temperature precip ruggedness latitude longitude, abs(year#codccaa) vce(robust)
outreg2 using "Tables/TableA4.tex", append dec(3) adj

*cluster cpj_year
gen cpj_year=hist_cpj*year
reghdfe genderpc stem_std numparties pop pop2 bigcity sup coastal calories_muni temperature precip ruggedness latitude longitude, abs(year#codccaa) cluster(cpj_year)
outreg2 using "Tables/TableA4.tex", append dec(3) adj
*Conley
gen year_codccaa=year*codccaa
preserve
drop if latitud==.
acreg genderpc stem_std numparties pop pop2 bigcity sup coastal calories_muni temperature precip ruggedness latitude longitude, spatial ///
latitude(latitud) longitude(longitud) dist(10) pfe1(year_codccaa)  correctr2
outreg2 using "Tables/TableA4Conley.tex", replace dec(3) 
acreg genderpc stem_std numparties pop pop2 bigcity sup coastal calories_muni temperature precip ruggedness latitude longitude, spatial ///
latitude(latitud) longitude(longitud) dist(20) pfe1(year_codccaa)  correctr2 
outreg2 using "Tables/TableA4Conley.tex", append dec(3) 
acreg genderpc stem_std numparties pop pop2 bigcity sup coastal calories_muni temperature precip ruggedness latitude longitude, spatial ///
latitude(latitud) longitude(longitud) dist(30) pfe1(year_codccaa)  correctr2
outreg2 using "Tables/TableA4Conley.tex", append dec(3)  
acreg genderpc stem_std numparties pop pop2 bigcity sup coastal calories_muni temperature precip ruggedness latitude longitude, spatial ///
latitude(latitud) longitude(longitud) dist(40) pfe1(year_codccaa)  correctr2 
outreg2 using "Tables/TableA4Conley.tex", append dec(3) 
restore


**# Appendix Figure A-4: with cluster(hist_cpj)
preserve
reghdfe genderpc c.stem_std##i.year pop pop2 numparties bigcity sup coastal calories_muni temperature ruggedness precip longitude latitude, abs(codccaa) cluster(hist_cpj) 
margins year, dydx(stem_std) saving(myfile, replace)
bysort year: sum genderpc if e(sample)
* Mean of DV 
* This code computes the mean of the DV per year and saves it.
reghdfe genderpc c.stem_std##i.year pop pop2 numparties bigcity sup coastal calories_muni temperature ruggedness precip longitude latitude, abs(codccaa) cluster(hist_cpj)
keep if e(sample)
bysort year: egen mean_genderpc = mean(genderpc) 
bysort year: gen count = _n
keep if count == 1
keep year mean_genderpc
sort year
gen election = _n
keep election mean_genderpc
save mean_dv.dta, replace
* Merge Margins' estimates and mean of DV
use myfile, clear
gen election = _n
merge 1:1 election using "mean_dv.dta"
gen relative_impact = 100*_margin/mean_genderpc
* Make all weights positive
gen pos_relative_impact = abs(relative_impact)
* Slightly modified color scheme (Stata 18)
set scheme stcolor
twoway (scatter _margin _m1  [w=pos_relative_impact], sort mlcolor(black))  (rcap _ci_lb _ci_ub _m1, sort pstyle(ci) color(navy) legend(off) yline(0) xlab(1976 " "  1979 `" "1979" "(2.92)" "'  1983 `" "1983" "(4.32)" "' 1987 `" "1987" "(6.81)" "'  1991 `" "1991" "(10.80)" "' 1995 `" "1995" "(15.00)" "' 1999 `" "1999" "(20.97)" "' 2003 `" "2003" "(25.58)" "' 2007 `" "2007" "(30.07)" "' 2011 `" "2011" "(33.08)" "' 2015 `" "2015" "(36.15)" "' 2017 " ") ytitle("Marginal effect of Stem Family" "on % of Elected Women") xtitle(""))
graph export "Figures/FigureA4.pdf", replace
restore

**# Appendix Figure A-5 with double cluster(codiine year)
preserve
reghdfe genderpc c.stem_std##i.year pop pop2 numparties bigcity sup coastal calories_muni temperature ruggedness precip longitude latitude, abs(codccaa) cluster(codiine year) 
margins year, dydx(stem_std) saving(myfile, replace)
bysort year: sum genderpc if e(sample)
* Mean of DV 
* This code computes the mean of the DV per year and saves it.
reghdfe genderpc c.stem_std##i.year pop pop2 numparties bigcity sup coastal calories_muni temperature ruggedness precip longitude latitude, abs(codccaa) cluster(codiine year)
keep if e(sample)
bysort year: egen mean_genderpc = mean(genderpc) 
bysort year: gen count = _n
keep if count == 1
keep year mean_genderpc
sort year
gen election = _n
keep election mean_genderpc
save mean_dv.dta, replace
* Merge Margins' estimates and mean of DV
use myfile, clear
gen election = _n
merge 1:1 election using "mean_dv.dta"
gen relative_impact = 100*_margin/mean_genderpc
* Make all weights positive
gen pos_relative_impact = abs(relative_impact)
* Slightly modified color scheme (Stata 18)
set scheme stcolor
twoway (scatter _margin _m1  [w=pos_relative_impact], sort mlcolor(black))  (rcap _ci_lb _ci_ub _m1, sort pstyle(ci) color(navy) legend(off) yline(0) xlab(1976 " "  1979 `" "1979" "(2.92)" "'  1983 `" "1983" "(4.32)" "' 1987 `" "1987" "(6.81)" "'  1991 `" "1991" "(10.80)" "' 1995 `" "1995" "(15.00)" "' 1999 `" "1999" "(20.97)" "' 2003 `" "2003" "(25.58)" "' 2007 `" "2007" "(30.07)" "' 2011 `" "2011" "(33.08)" "' 2015 `" "2015" "(36.15)" "' 2017 " ") ytitle("Marginal effect of Stem Family" "on % of Elected Women") xtitle(""))
graph export "Figures/FigureA5.pdf", replace
restore

**# Appendix Figure A-6 with double cluster(hist_cpj year)
preserve
reghdfe genderpc c.stem_std##i.year pop pop2 numparties bigcity sup coastal calories_muni temperature ruggedness precip longitude latitude, abs(codccaa) cluster(hist_cpj year)
margins year, dydx(stem_std) saving(myfile, replace)
bysort year: sum genderpc if e(sample)
* Mean of DV 
* This code computes the mean of the DV per year and saves it.
reghdfe genderpc c.stem_std##i.year pop pop2 numparties bigcity sup coastal calories_muni temperature ruggedness precip longitude latitude, abs(codccaa) cluster(hist_cpj year)
keep if e(sample)
bysort year: egen mean_genderpc = mean(genderpc) 
bysort year: gen count = _n
keep if count == 1
keep year mean_genderpc
sort year
gen election = _n
keep election mean_genderpc
save mean_dv.dta, replace
* Merge Margins' estimates and mean of DV
use myfile, clear
gen election = _n
merge 1:1 election using "mean_dv.dta"
gen relative_impact = 100*_margin/mean_genderpc
* Make all weights positive
gen pos_relative_impact = abs(relative_impact)
* Slightly modified color scheme (Stata 18)
set scheme stcolor
twoway (scatter _margin _m1  [w=pos_relative_impact], sort mlcolor(black))  (rcap _ci_lb _ci_ub _m1, sort pstyle(ci) color(navy) legend(off) yline(0) xlab(1976 " "  1979 `" "1979" "(2.92)" "'  1983 `" "1983" "(4.32)" "' 1987 `" "1987" "(6.81)" "'  1991 `" "1991" "(10.80)" "' 1995 `" "1995" "(15.00)" "' 1999 `" "1999" "(20.97)" "' 2003 `" "2003" "(25.58)" "' 2007 `" "2007" "(30.07)" "' 2011 `" "2011" "(33.08)" "' 2015 `" "2015" "(36.15)" "' 2017 " ") ytitle("Marginal effect of Stem Family" "on % of Elected Women") xtitle(""))
graph export "Figures/FigureA6.pdf", replace
restore


**# Appendix Figure A-7 with robust
preserve
reghdfe genderpc c.stem_std##i.year pop pop2 numparties bigcity sup coastal calories_muni temperature ruggedness precip longitude latitude, abs(codccaa) vce(robust)
margins year, dydx(stem_std) saving(myfile, replace)
bysort year: sum genderpc if e(sample)
* Mean of DV 
* This code computes the mean of the DV per year and saves it.
reghdfe genderpc c.stem_std##i.year pop pop2 numparties bigcity sup coastal calories_muni temperature ruggedness precip longitude latitude, abs(codccaa) vce(robust)
keep if e(sample)
bysort year: egen mean_genderpc = mean(genderpc) 
bysort year: gen count = _n
keep if count == 1
keep year mean_genderpc
sort year
gen election = _n
keep election mean_genderpc
save mean_dv.dta, replace
* Merge Margins' estimates and mean of DV
use myfile, clear
gen election = _n
merge 1:1 election using "mean_dv.dta"
gen relative_impact = 100*_margin/mean_genderpc
* Make all weights positive
gen pos_relative_impact = abs(relative_impact)
* Slightly modified color scheme (Stata 18)
set scheme stcolor
twoway (scatter _margin _m1  [w=pos_relative_impact], sort mlcolor(black))  (rcap _ci_lb _ci_ub _m1, sort pstyle(ci) color(navy) legend(off) yline(0) xlab(1976 " "  1979 `" "1979" "(2.92)" "'  1983 `" "1983" "(4.32)" "' 1987 `" "1987" "(6.81)" "'  1991 `" "1991" "(10.80)" "' 1995 `" "1995" "(15.00)" "' 1999 `" "1999" "(20.97)" "' 2003 `" "2003" "(25.58)" "' 2007 `" "2007" "(30.07)" "' 2011 `" "2011" "(33.08)" "' 2015 `" "2015" "(36.15)" "' 2017 " ") ytitle("Marginal effect of Stem Family" "on % of Elected Women") xtitle(""))
graph export "Figures/FigureA7.pdf", replace
restore


**# Appendix Figure A-8 with cluster cpj_year
preserve
reghdfe genderpc c.stem_std##i.year pop pop2 numparties bigcity sup coastal calories_muni temperature ruggedness precip longitude latitude, abs(codccaa) cluster(cpj_year)
bysort year: sum genderpc if e(sample)
* Mean of DV 
* This code computes the mean of the DV per year and saves it.
reghdfe genderpc c.stem_std##i.year pop pop2 numparties bigcity sup coastal calories_muni temperature ruggedness precip longitude latitude, abs(codccaa) cluster(cpj_year)
keep if e(sample)
bysort year: egen mean_genderpc = mean(genderpc) 
bysort year: gen count = _n
keep if count == 1
keep year mean_genderpc
sort year
gen election = _n
keep election mean_genderpc
save mean_dv.dta, replace
* Merge Margins' estimates and mean of DV
use myfile, clear
gen election = _n
merge 1:1 election using "mean_dv.dta"
gen relative_impact = 100*_margin/mean_genderpc
* Make all weights positive
gen pos_relative_impact = abs(relative_impact)
* Slightly modified color scheme (Stata 18)
set scheme stcolor
twoway (scatter _margin _m1  [w=pos_relative_impact], sort mlcolor(black))  (rcap _ci_lb _ci_ub _m1, sort pstyle(ci) color(navy) legend(off) yline(0) xlab(1976 " "  1979 `" "1979" "(2.92)" "'  1983 `" "1983" "(4.32)" "' 1987 `" "1987" "(6.81)" "'  1991 `" "1991" "(10.80)" "' 1995 `" "1995" "(15.00)" "' 1999 `" "1999" "(20.97)" "' 2003 `" "2003" "(25.58)" "' 2007 `" "2007" "(30.07)" "' 2011 `" "2011" "(33.08)" "' 2015 `" "2015" "(36.15)" "' 2017 " ") ytitle("Marginal effect of Stem Family" "on % of Elected Women") xtitle(""))
graph export "Figures/FigureA8.pdf", replace
restore



**# Table A-5 Dynamic and cluster district
* 1 
reghdfe genderpc c.stem_std##i.year, noabs cluster(hist_cpj)
margins year, dydx(stem_std) post
outreg2 using "Tables/TableA5.tex", replace dec(3) 
*2 
reghdfe genderpc c.stem_std##i.year numparties pop pop2 bigcity, noabs cluster(hist_cpj)
margins year, dydx(stem_std) post
outreg2 using "Tables/TableA5.tex", append dec(3) 
*3: 
reghdfe genderpc c.stem_std##i.year numparties pop pop2 bigcity ///
sup coastal calories_muni temperature precip ruggedness latitud longitud, noabs cluster(hist_cpj)
margins year, dydx(stem_std) post
outreg2 using "Tables/TableA5.tex", append dec(3) 
*4
reghdfe genderpc c.stem_std##i.year numparties pop pop2 bigcity ///
sup coastal calories_muni temperature precip ruggedness latitud longitud, abs(codccaa) cluster(hist_cpj)
margins year, dydx(stem_std) post
outreg2 using "Tables/TableA5.tex", append dec(3) 
*5
reghdfe genderpc i.stem_dummy##i.year numparties pop pop2 bigcity ///
sup coastal calories_muni temperature precip ruggedness latitud longitud, noabs cluster(hist_cpj)
margins year, dydx(stem_dummy) post
outreg2 using "Tables/TableA5.tex", append dec(3) 

**# Table A-6 Dynamic Effects with Additional Controls, and cluster (historical) district
* 1 sex ratio
reghdfe genderpc c.stem_std##i.year numparties pop pop2 bigcity sup coastal calories_muni temperature precip ruggedness latitude longitude sex_ratio, abs(codccaa) cluster(hist_cpj)
margins year, dydx(stem_std) post
outreg2 using "Tables/TableA6.tex", replace dec(3) 
*2 share of male singles
reghdfe genderpc c.stem_std##i.year numparties pop pop2 bigcity sup coastal calories_muni temperature precip ruggedness latitude longitude  singles_per_inhab, abs(codccaa) cluster(hist_cpj)
margins year, dydx(stem_std) post
outreg2 using "Tables/TableA6.tex", append dec(3) 
*3: religious
reghdfe genderpc c.stem_std##i.year numparties pop pop2 bigcity sup coastal calories_muni temperature precip ruggedness latitude longitude ///
share_priests share_nuns_monks share_mass_att, abs(codccaa) cluster(hist_cpj)
margins year, dydx(stem_std) post
outreg2 using "Tables/TableA6.tex", append dec(3) 
*4: land inequality
reghdfe genderpc c.stem_std##i.year numparties pop pop2 bigcity sup coastal calories_muni temperature precip ruggedness latitude longitude ///
ratio_laborers_landlords share_ag_pop, abs(codccaa) cluster(hist_cpj)
margins year, dydx(stem_std) post
outreg2 using "Tables/TableA6.tex", append dec(3) 
*5: share internal migrants
reghdfe genderpc c.stem_std##i.year numparties pop pop2 bigcity sup coastal calories_muni temperature precip ruggedness latitude longitude share_migrant, abs(codccaa) cluster(hist_cpj)
margins year, dydx(stem_std) post
outreg2 using "Tables/TableA6.tex", append dec(3) 
*6: excluding bcn and vizcaya
reghdfe genderpc c.stem_std##i.year numparties pop pop2 bigcity sup coastal calories_muni temperature precip ruggedness latitude longitude if (cprov!=8 & cprov!=48), abs(codccaa) cluster(hist_cpj)
margins year, dydx(stem_std) post
outreg2 using "Tables/TableA6.tex", append dec(3) 
*7: excluding all cities stem
reghdfe genderpc c.stem_std##i.year numparties pop pop2 sup coastal calories_muni temperature precip ruggedness latitude longitude if bigcity_stem==0, abs(codccaa) cluster(hist_cpj)
margins year, dydx(stem_std) post
outreg2 using "Tables/TableA6.tex", append dec(3) 

**# Table A-7: Quota Analysis with Municipality FE, and cluster district
*column 1 (Both Dummies)
reghdfe genderpc i.nuclear_dum##i.quota_binary pop pop2 numparties bigcity, abs(year codiine) cluster(hist_cpj)
outreg2 using "Tables/TableA7.tex", replace dec(3) label adj
*column 2 (Both continuous)
reghdfe genderpc c.nuclear_cont##c.quota pop pop2 numparties bigcity, abs(year codiine) cluster(hist_cpj)
outreg2 using "Tables/TableA7.tex", append dec(3) label adj


**# Table A-8: IV estimates, by year
*ssc inst ivreg2
*ssc install ranktest
ivreg2 genderpc (stem_std=descent) pop pop2 sup numparties bigcity coastal calories_muni temperature precip ruggedness if year== 1979, cluster(cprov) sfirst savesfirst 
outreg2 using "Tables/TableA8.tex", replace dec(3) 
ivreg2 genderpc (stem_std=descent) pop pop2 sup numparties bigcity coastal calories_muni temperature precip ruggedness if year== 1983, cluster(cprov) sfirst savesfirst
outreg2 using "Tables/TableA8.tex", append dec(3)  
ivreg2 genderpc (stem_std=descent) pop pop2 sup numparties bigcity coastal calories_muni temperature precip ruggedness if year== 1987, cluster(cprov) sfirst savesfirst
outreg2 using "Tables/TableA8.tex", append dec(3) 
ivreg2 genderpc (stem_std=descent) pop pop2 sup numparties bigcity coastal calories_muni temperature precip ruggedness if year== 1991, cluster(cprov) sfirst savesfirst
outreg2 using "Tables/TableA8.tex", append dec(3) 
ivreg2 genderpc (stem_std=descent) pop pop2 sup numparties bigcity coastal calories_muni temperature precip ruggedness if year== 1995, cluster(cprov) sfirst savesfirst
outreg2 using "Tables/TableA8.tex", append dec(3) 
ivreg2 genderpc (stem_std=descent) pop pop2 sup numparties bigcity coastal calories_muni temperature precip ruggedness if year== 1999, cluster(cprov) sfirst savesfirst
outreg2 using "Tables/TableA8.tex", append dec(3) 
ivreg2 genderpc (stem_std=descent) pop pop2 sup numparties bigcity coastal calories_muni temperature precip ruggedness if year== 2003, cluster(cprov) sfirst savesfirst
outreg2 using "Tables/TableA8.tex", append dec(3) 
ivreg2 genderpc (stem_std=descent) pop pop2 sup numparties bigcity coastal calories_muni temperature precip ruggedness if year== 2007, cluster(cprov) sfirst savesfirst 
outreg2 using "Tables/TableA8.tex", append dec(3) 
ivreg2 genderpc (stem_std=descent) pop pop2 sup numparties bigcity coastal calories_muni temperature precip ruggedness if year== 2011, cluster(cprov) sfirst savesfirst
outreg2 using "Tables/TableA8.tex", append dec(3) 
ivreg2 genderpc (stem_std=descent) pop pop2 sup numparties bigcity coastal calories_muni temperature precip ruggedness if year== 2015, cluster(cprov) sfirst savesfirst
outreg2 using "Tables/TableA8.tex", append dec(3) 

* first-stage results
reg stem_std descent pop pop2 sup numparties bigcity coastal calories_muni temperature precip ruggedness if year== 1979 & genderpc!=., cluster(cprov)
outreg2 using "Tables/TableA8FistStage.tex", replace dec(3) 
reg stem_std descent pop pop2 sup numparties bigcity coastal calories_muni temperature precip ruggedness if year== 1983 & genderpc!=., cluster(cprov) 
outreg2 using "Tables/TableA8FistStage.tex", append dec(3) 
reg stem_std descent pop pop2 sup numparties bigcity coastal calories_muni temperature precip ruggedness if year== 1987 & genderpc!=., cluster(cprov) 
outreg2 using "Tables/TableA8FistStage.tex", append dec(3) 
reg stem_std descent pop pop2 sup numparties bigcity coastal calories_muni temperature precip ruggedness if year== 1991 & genderpc!=., cluster(cprov) 
outreg2 using "Tables/TableA8FistStage.tex", append dec(3) 
reg stem_std descent pop pop2 sup numparties bigcity coastal calories_muni temperature precip ruggedness if year== 1995 & genderpc!=., cluster(cprov) 
outreg2 using "Tables/TableA8FistStage.tex", append dec(3) 
reg stem_std descent pop pop2 sup numparties bigcity coastal calories_muni temperature precip ruggedness if year== 1999 & genderpc!=., cluster(cprov) 
outreg2 using "Tables/TableA8FistStage.tex", append dec(3) 
reg stem_std descent pop pop2 sup numparties bigcity coastal calories_muni temperature precip ruggedness if year== 2003 & genderpc!=., cluster(cprov) 
outreg2 using "Tables/TableA8FistStage.tex", append dec(3) 
reg stem_std descent pop pop2 sup numparties bigcity coastal calories_muni temperature precip ruggedness if year== 2007 & genderpc!=., cluster(cprov) 
outreg2 using "Tables/TableA8FistStage.tex", append dec(3) 
reg stem_std descent pop pop2 sup numparties bigcity coastal calories_muni temperature precip ruggedness if year== 2011 & genderpc!=., cluster(cprov) 
outreg2 using "Tables/TableA8FistStage.tex", append dec(3) 
reg stem_std descent pop pop2 sup numparties bigcity coastal calories_muni temperature precip ruggedness if year== 2015 & genderpc!=., cluster(cprov) 
outreg2 using "Tables/TableA8FistStage.tex", append dec(3) 


**# Figure A-10: IV coefficients by year
foreach num of numlist 1979 1983 1987 1991 1995 1999 2003 2007 2011 2015 {
	ivreg2 genderpc (stem_std=descent) pop pop2 sup numparties bigcity coastal calories_muni temperature precip ruggedness if year==`num', cluster(cprov)
	estimates store iv_`num'
} 
*ssc install blindschemes
*ssc install coefplot
set scheme plotplain
coefplot (iv_1979, label(1979)) (iv_1983, label(1983)) (iv_1987, label(1987)) ///
	(iv_1991, label(1991)) (iv_1995, label(1995)) (iv_1999, label(1999)) (iv_2003, label(2003)) ///
	(iv_2007, label(2007)) (iv_2011, label(2011)) (iv_2015, label(2015)) , ///
	keep(stem_std) legend(position(6)) yline(0) vertical legend( col(5)) coeflabels(stem_std = " ")  ///
	ytitle(IV estimate of stem family on share elected women)
*%%% Below xline cuts to manually add labels in x axis in formatted figure
*%%% xline(0.59 0.68 .772 .862 .955 1.045 1.135 1.225 1.32 1.41)
graph export "Figures/FigureA10.pdf", replace


**# Table A-9: Women Literacy in the 19th century by family type
preserve
do "Codes/Table_A9_female_literacy_1887.do"
restore

**# Figure A-11: Share of women councilors by historical family type
preserve
do "Codes/Figure_A11_councilors_historic.do"
restore

**# Figure A-12: Timing of Voluntary Electoral Quotas in Spain. From Verge (2012)


**# Table A-10: Municipality and year FEs
reghdfe genderpc nuclear_dum##year numparties pop pop2 bigcity, abs(codiine) cluster(codiine)
outreg2 using "Tables/TableA10.tex", replace dec(3) label adj


**# Figure A-13: quotas by PSOE 
gen post1988=0 if year<1988 
replace post1988=1 if year>=1988
replace post1988=. if year==.
label define post1988_lab 0 "Before Voluntary Quota" 1 "After Voluntary Quota"
label values post1988 post1988_lab
reg genderpc i.nuclear_dum##i.post1988 numparties pop pop2 bigcity sup coastal calories_muni temperature precip ruggedness latitude longitude i.year i.codccaa if psoe==1, cluster(codiine)
margins, dydx(nuclear_dum) by(post1988)
marginsplot, yline(0) ytitle("Marginal Effect of Nuclear Family Tradition" "on Women Representation") title(Only towns with PSOE representation) xlab(-.2 " " 0 `" "Before" "Voluntary" "Quota""' 1 `" "After" "Voluntary" "Quota"' 1.2 " ", noticks) xtitle(" ")
graph export "Figures/FigureA13.pdf", replace











